package shmallarchitect.jpa.entities;
// Generated 2009-08-23 21:22:13 by Hibernate Tools 3.2.1.GA


import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * Resource generated by hbm2java
 */
@Entity
@Table(name="resource"
    ,catalog="shmall_architect"
)
public class Resource  implements java.io.Serializable {


     private Long id;
     private String uri;
     private Set<Card> cards = new HashSet<Card>(0);

    public Resource() {
    }

	
    public Resource(String uri) {
        this.uri = uri;
    }
    public Resource(String uri, Set<Card> cards) {
       this.uri = uri;
       this.cards = cards;
    }
   
     @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="uri", nullable=false)
    public String getUri() {
        return this.uri;
    }
    
    public void setUri(String uri) {
        this.uri = uri;
    }
@ManyToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
    @JoinTable(name="cardresource", catalog="shmall_architect", joinColumns = { 
        @JoinColumn(name="resource_id", nullable=false, updatable=false) }, inverseJoinColumns = { 
        @JoinColumn(name="card_id", nullable=false, updatable=false) })
    public Set<Card> getCards() {
        return this.cards;
    }
    
    public void setCards(Set<Card> cards) {
        this.cards = cards;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Resource other = (Resource) obj;
        if ((this.uri == null) ? (other.uri != null) : !this.uri.equals(other.uri)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 89 * hash + (this.uri != null ? this.uri.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return uri;
    }




}


